#ifndef __I2C_HAL_H__
#define __I2C_HAL_H__

#define I2C_USED            I2C1
#define I2C_CLK             RCC_APB1Periph_I2C1
#define I2C_CLOCK_HZ        100000

#define I2C_GPIO_PORT       GPIOB
#define I2C_GPIO_CLK        RCC_AHB1Periph_GPIOB
#define I2C_SCL_PIN         GPIO_Pin_8
#define I2C_SDA_PIN         GPIO_Pin_9

#define I2C_AF_GPIO         GPIO_AF_I2C1
#define I2C_SCL_SOURCE      GPIO_PinSource8
#define I2C_SDA_SOURCE      GPIO_PinSource9

enum X_I2C_MODE {
    READ = 1,
    WRITE = 0
};

#ifdef __cplusplus
extern "C" {
#endif

/* Very simple I2C APIs */

void i2c_open(void);
void i2c_close(void);
unsigned long i2c_read(unsigned char slave_address, unsigned char from_address, unsigned long length, unsigned char *pdata);
unsigned long i2c_write(unsigned char slave_address, unsigned char from_address, unsigned long length, unsigned char *pdata);
#ifdef __cplusplus
}
#endif
#endif /* __I2C_HAL_H__ */